package com.handong.handserialprogram.broadcastreceiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import com.handong.handserialprogram.module.serialport.SerialPortUtil;

/**
 * Created by userKey on 2017/4/20.
 */

public class ShutDownBroadCastReceiver extends BroadcastReceiver {
    private SerialPortUtil mSerialPortUtil;
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d("handong", "ShutDownBroadCastReceiver receive broadcast.");
        //MainActivity就是开机显示的界面

        if( Intent.ACTION_SHUTDOWN.equals(intent.getAction()))
        {
            mSerialPortUtil=SerialPortUtil.getInstance(context);
                if (mSerialPortUtil!=null)
                {
                    mSerialPortUtil.closeSerialPort();
                }
        }
        Log.d("handong", "Intent.ACTION_SHUTDOWN");
    }
}